<?php
declare(strict_types=1);

namespace app\validate;

use think\Validate;

class Admin extends Validate
{
    /**
     * 定义验证规则
     */
    protected $rule = [
        'username' => 'require|regex:\w{3,16}|unique:admin',
        'password' => 'require|regex:\S{6,32}'
    ];

    /**
     * 定义错误信息
     */
    protected $message = [];

    /**
     * 编辑的时候，不去验证密码
     */
    public function sceneEdit()
    {
        return $this->remove('password', 'require');
    }

    public function __construct()
    {
        //返回提示信息
        $this->field = [
            'username' => '用户名',
            'password' => '密码',
        ];
        parent::__construct();
    }
}
